<%@ page language="java" pageEncoding="UTF-8"%>
<%@page import="com.shsh.safemanage.action.WriteProblemAction"%>
<%@page import="com.shsh.safemanage.action.ActionCreator"%>
<%@page import="com.shsh.safemanage.action.UserAction"%>
<%@page import="com.shsh.safemanage.dao.ProblemDao"%>
<%@page import="com.shsh.safemanage.model.Problem"%>
<%@page import="com.shsh.safemanage.model.User"%>
<%@page import="com.shsh.safemanage.dao.UserDao"%>
<%@page import="com.shsh.safemanage.util.Util"%>
<%@page import="com.shsh.safemanage.model.Department1"%>
<%@page import="java.util.List"%>
<%@page import="com.shsh.safemanage.dao.DepartmentDao"%>
<%@page import="com.shsh.safemanage.dao.DaoCreator"%>
<%@page import="com.shsh.safemanage.util.Constants"%>

<%
String theProblemIDStr = request.getParameter(Constants.REQUEST_PARAMETER_ID);
WriteProblemAction writeProblemAction = ActionCreator.createWriteProblemAction();
List<User> userList = writeProblemAction.getEscalateUserList(request);
%>
<%
if (userList.size() > 0) {
%>
<div style="overflow: auto;">
<table border="1" cellpadding="0" cellspacing="0">
	<%
	for (int i = 0; i < 100; i++) {
		boolean isBreak = false;
	%>
	<tr>
		<%
		for (int j = 0; j < 4; j++) {
			int index = i * 4 + j;
			if (index >= userList.size()) {
				isBreak = true;
				break;
			}
			User user = userList.get(index);
		%>
		<td align="center" width="100">
			<span><a href="javascript:" onclick="chooseEscalateUser(<%=user.getId()%>)"><%=user.getName()%></a></span>
		</td>
		<%
		}
		%>
	</tr>
	<%
		if (isBreak) {
			break;
		}
	}
	%>
</table>
</div>
<%
}
%>

<script type="text/javascript">
function chooseEscalateUser(userID) {
	openWaitingDialog('waitingDialog');
	
	$.dialog.get('escalateUserDialog').close();
	
	$.ajax({
		type:'post',
		url:'choose_feedback_escalateuser_process.jsp',
		data:{
			id: userID
		},
		success:function(data,state,xmlhttp){
			var obj = null;
			try {
				obj = eval('(' + data + ')');
			} catch (e) {
			}
			if (typeof(obj.isSuccess) != 'undefined') {
				closeWaitingDialog('waitingDialog');
				if (obj.isSuccess == 'true') {
					loadPageSection('<%=request.getContextPath()%>/shutdown/feedback_process_method.jsp', 'feedbackProcessMethodDiv', {id:<%=theProblemIDStr%>}, false, 
					function() {
						var processRadio3 = document.getElementById('processRadio3');
						if (processRadio3 != null) {
							processRadio3.checked = true;
						}
						chooseProcessMethod(3);
						
						var processRadio5 = document.getElementById('processRadio5');
						if (processRadio5 != null) {
							processRadio5.checked = true;
						}
						chooseProcessMethod(5);
					});
				} else {
					$.dialog.alert(obj.error);
				}
			}
		}
	});
}
</script>
